@isTest
public class AssetProjectControllerTest
{
    static testMethod void AssetProjectControllerTest()
    {
        
        ProductStructure__c ps=new ProductStructure__c();
        ps.Classify2__c='尿液-22';
        ps.Classify3__c='试剂';
        ps.Classify1__c='临检';
        insert ps;
        
        ProductProject__c pp=new ProductProject__c();
        pp.Name='项目111';
        pp.ProductStructure__c=ps.Id;
        //pp.Brand__c='迈克生物/maccura';
        insert pp;
        
        
        Product__c product = new Product__c();
        product.Category1__c='临检'; 
        product.Name='全自动尿有形成份分析仪'; 
        product.Category3__c='SYSMEX-XN专用'; 
        product.Category4__c='尿液分析仪'; 
        product.Category2__c='尿液-11'; 
        product.Unit__c='台'; 
        product.SerialNo__c='UF-1000i'; 
        product.Brand__c='济南希森美康'; 
        product.Category0__c='仪器'; 
        product.Model__c='Mdele1';
        product.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('CompetitorProduct', 'Product__c');
        insert product;
        
        Account acc=new Account();
        acc.Name='Test1229J';
        insert acc;
        
        Equipment__c equip = new Equipment__c();
        //equip.Name = '测试用仪器名称';
        equip.Product__c=product.Id;
        equip.Account__c=acc.Id;
        //equip.Brand__c='迈克生物/maccura';
        insert equip;
        
        AssetProject__c ap=new AssetProject__c();
        ap.Name='资产项目111';
        ap.Instrument__c = equip.id;
        ap.ProductProject__c = pp.Id;
        insert ap;
        
        String eid=equip.Id;
           
        // ---------------------新建-----------------------
        PageReference page = new PageReference('/apex/CreateAssetProject?eid=' + eid);
        System.Test.setCurrentPage(page);
        AssetProjectController apc=new AssetProjectController(new ApexPages.StandardController(new AssetProject__c()));
        apc.init();

        System.assertEquals(1, apc.oldList.size()); 
        System.assertEquals(1, apc.apList.size()); 

        apc.apList[0].chk = true;
        apc.save();
        
        List<AssetProject__c> q = [select Id from AssetProject__c where Instrument__c = :eid];
       // System.assertEquals(1, q.size());  
        
        apc.init();
        //System.assertEquals(1, apc.oldList.size()); 
    }
}